/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-04-30
 * Time: 23:51
 */
public class Hanoi {
    public static int sum = 0;
    public static void hanoi(int n, String a, String b, String c) {
        /** n表示总共有几个盘子
         *  a表示当前的塔，b表示中转塔，c表示目标塔,（注意：他们递归时会改变）
         */
        if (n == 1) {
            System.out.println(a + "-->" + c);//每次移动到C塔,SUM来计数
            sum++;
        } else {
            hanoi(n-1, a, c, b );
            System.out.println(a + "-->" + c);
            sum++;
            hanoi(n-1, b, a, c);
        }
    }
    public static void main(String[] args) {
        hanoi(5, "Current", "transfer", "goal");
        System.out.println(sum);
    }
}
